/**
 *                            License
 * THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS  
 * CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). 
 * THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW.  
 * ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR  
 * COPYRIGHT LAW IS PROHIBITED.
 * 
 * BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND  
 * AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE  
 * MAY BE CONSIDERED TO BE A CONTRACT,
 * THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED 
 * HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
 * 
 */
package com.lineage.server.utils;

/**
 * Class <code>PerformanceTimer</code> 执行时间计算器.
 * 
 * @author jrwz
 * @version 2012-5-8上午11:31:12
 * @see com.lineage.server.utils
 * @since JDK1.7
 */
public final class PerformanceTimer {

    /** 正在运行的Java虚拟机的高清晰度的时间源的电流值，单位:纳秒. */
    private long _begin = System.nanoTime();

    /**
     * 运行时间:微秒.
     * 
     * @return 时间差
     */
    public long elapsedTimeMicros() {
        return (System.nanoTime() - this._begin) / 1000;
    }

    /**
     * 运行时间:毫秒.
     * 
     * @return 时间差
     */
    public long elapsedTimeMillis() {
        return (System.nanoTime() - this._begin) / 1000 / 1000;
    }

    /**
     * 运行时间:纳秒.
     * 
     * @return 时间差
     */
    public long elapsedTimeNanos() {
        return System.nanoTime() - this._begin;
    }

    /** 重置运行时间. */
    public void reset() {
        this._begin = System.nanoTime();
    }
}
